package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.domain.dao.LSzxqgx;
import com.ruoyi.service.ILSzxqgxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;


import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * @author zxw
 * @date 2025-07-09
 */
@Api(tags = "业务——市政和小区管线管理")
@RestController
@RequestMapping("/admin/szxqgx")
public class LSzxqgxController extends BaseController
{
    @Autowired
    private ILSzxqgxService lSzxqgxService;

    @GetMapping("/list")
    @ApiOperation("多条件查询管线")
    public TableDataInfo list(LSzxqgx lSzxqgx)
    {
        startPage();
        List<LSzxqgx> list = lSzxqgxService.selectLSzxqgxList(lSzxqgx);
        return getDataTable(list);
    }


    @PostMapping("/export")
    @ApiOperation("excel导出管线")
    public void export(HttpServletResponse response, LSzxqgx lSzxqgx)
    {
        List<LSzxqgx> list = lSzxqgxService.selectLSzxqgxList(lSzxqgx);
        ExcelUtil<LSzxqgx> util = new ExcelUtil<LSzxqgx>(LSzxqgx.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    @ApiOperation("按照gid查询管线")
    @GetMapping(value = "/{gid}")
    public AjaxResult getInfo(@PathVariable("gid") Long gid)
    {
        return success(lSzxqgxService.selectLSzxqgxByGid(gid));
    }

    @ApiOperation("新增管线")
    @PostMapping
    public AjaxResult add(@RequestBody LSzxqgx lSzxqgx)
    {
        return toAjax(lSzxqgxService.insertLSzxqgx(lSzxqgx));
    }

    @ApiOperation("编辑管线")
    @PutMapping
    public AjaxResult edit(@RequestBody LSzxqgx lSzxqgx)
    {
        return toAjax(lSzxqgxService.updateLSzxqgx(lSzxqgx));
    }

    @ApiOperation("删除管线")
	@DeleteMapping("/{gids}")
    public AjaxResult remove(@PathVariable Long[] gids)
    {
        return toAjax(lSzxqgxService.deleteLSzxqgxByGids(gids));
    }

    @ApiOperation("小区管线道路唯一值")
    @GetMapping(value = "/estateDistinct")
    public AjaxResult estateDistinct()
    {
        return success(lSzxqgxService.estateDistinct());
    }

    @ApiOperation("市政管线区域唯一值")
    @GetMapping(value = "/roadDistinct")
    public AjaxResult roadDistinct()
    {
        return success(lSzxqgxService.roadDistinct());
    }

    @ApiOperation("按照管道号查询")
    @GetMapping(value = "/findByPipeNum")
    public AjaxResult findByPipeNum(@RequestParam("pipeNum") String pipeNum)
    {
        return success(lSzxqgxService.findByPipeNum(pipeNum));
    }


}
